﻿
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>云瑞家庭农场</title>
    <link rel="shortcut icon" href="~/Content/assets/i/miemie_favicon.ico" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/layui/layui.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-3.3.1.js"></script>
    <script type="text/javascript">
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            $(document).ready(function () {
                var _token = cookie("token");
                var Kind = getQueryString("Kind");
                $.ajax({
                    url: "/YunRuiFarmAPI/AdoptGetLoginMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "Token": _token,
                    }, //发送的参数
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {
                        if (result.IsSuccess)
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + result.Message)
                        else {
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + "请先登录")
                            $("#UsecCenter").html("<dd><a href=\"/YunRuiFarm/Login\">登录</a></dd>");
                            $("#Operation").html("");
                        }
                    });
                $.ajax({
                    url: "/YunRuiFarmAPI/AdoptGoatGetMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "Kind": Kind,
                    }, //发送的参数
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {

                    });
                $("#Cancellation").click(function () {
                    layer.msg("清除token");
                    delcookie("token", "", { expires: -1 });
                    window.location.href = "/YunRuiFarm/Login";
                });
                $("#Goat1").click(function () {
                    window.location.href = "/YunRuiFarm/AdoptGoat?Kind=山羊";
                });
                $("#Goat2").click(function () {
                    window.location.href = "/YunRuiFarm/AdoptGoat?Kind=湖羊";
                });
            });
            function getQueryString(name) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return unescape(r[2]);
                }
                return 1;
            }
            function GetUrlPara() {
                var url = document.location.toString();
                var arrUrl = url.split("=");
                var para = arrUrl[1];
                return para;
            }
            function cookie(key, value, options) {
                if (typeof value === "undefined") {
                    var cookies = document.cookie.split("; ");
                    for (var i = 0, len = cookies.length; i < len; i++) {
                        var cookie = cookies[i].split("=");
                        if (decodeURIComponent(cookie[0]) === key) {
                            return decodeURIComponent(cookie[1]);
                        }
                    }
                    return null;
                }
            }
            function delcookie(key, value, options) {
                options = options || {};
                var cookie = encodeURIComponent(key) + "=" + value;
                if ((typeof options.expires) !== "undefined") {
                    if (typeof options.expires === "number") {
                        var days = options.expires,
                            t = options.expires = new Date();
                        t.setDate(t.getDate() + days);
                    }
                    cookie += ";expires=" + options.expires.toUTCString();
                }
                if (typeof options.path !== "undefined")
                    cookie += ";path=" + options.path;
                if (typeof options.domain !== "undefined")
                    cookie += ";domain=" + options.domain;
                if (options.secure)
                    cookie += ";secure";
                document.cookie = cookie;
            }
        });
    </script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });
        var url = document.location.toString();
        var arrUrl = url.split("=");
        var para = arrUrl[1];


    </script>
    <style>
        body {
            font-size: 18px;
        }


        #content-left {
            width: 50%;
            height: 100%;
            float: left;
        }

        #content-right {
            width: 50%;
            height: 100%;
            float: right
        }

        #content-right-top {
            float: left;
            width: 98%;
            height: 40%;
            margin-right: 1%;
            margin-left: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
        }

        #content-right-bottom {
            float: left;
            width: 98%;
            height: 49%;
            margin-right: 1%;
            margin-left: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
        }

        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header" style="width:auto">
            <div class="layui-logo" style=" background-image: url('../../Content/image/logo.jpg');background-size:100% 100%;"></div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-left" style="font-size: 20px;">
                <li class="layui-nav-item"><a href="/YunRuiFarm/Index">首页</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Adopt">羊领养预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Agricultural">农副产品预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Restaurant">餐饮预约</a></li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;" id="Name">
                        <img src="/Content/image/小埋1.jpg" class="layui-nav-img" />请先登录
                    </a>
                    <dl class="layui-nav-child" id="UsecCenter">
                        <dd><a href="/YunRuiFarm/UserInfo">基本资料</a></dd>
                        <dd><a href="">我的订单</a></dd>
                        <dd><a href="/YunRuiFarm/UserFeedback">反馈信息</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" id="Operation">
                    <a href="javascript:;">账户操作</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/YunRuiFarm/AdministratorsGoatOrder">切换到管理员</a></dd>
                        <dd><a href="javascript:;" id="Cancellation">注销</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed">
                        <a class="" href="javascript:;">羊领养</a>
                        <dl class="layui-nav-child">
                            <dd><a href="/YunRuiFarm/Adopt">羊信息</a></dd>
                            <dd><a href="javascript:;">湖羊预约</a></dd>
                            <dd><a href="javascript:;">山羊预约</a></dd>
                            <dd><a href="javascript:;">我的订单</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>
        <div class="layui-body" style="background-color:#c0c0c0;height:100%;">
            <!-- 内容主体区域 -->
            <table class="layui-hide" id="test"></table>
            <div class="layui-form-item">
                <label class="layui-form-label">品种1</label>
                <div class="layui-input-inline">
                    <input type="text" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" readonly="readonly" id="kind1">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">品种2</label>
                <div class="layui-input-inline">
                    <input type="text" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" readonly="readonly" id="kind2">
                </div>
            </div>
        </div>


    </div>
    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test'//放入的控件，必填
                , url: '/YunRuiFarmAPI/try1GetMessageAPI'//输入链接
                , page: { 
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    , groups: 1 //只显示 1 个连续页码
                    , first: false //不显示首页
                    , last: false //不显示尾页

                }
                , cols: [[
                    { field: 'Id', width: 80, title: 'ID', sort: true }
                    , { field: 'Kind', width: 100, title: '品种' }
                    , { field: 'Total', width: 80, title: '总数量', sort: true }
                    , { field: 'Number', width: 80, title: '可领养数量' }
                    , { field: 'Createtime', title: '创建时间', minWidth: 150 }
                    , { field: 'Updatetime', width: 80, title: '修改时间', sort: true }//这是表格形式的，不用管
                ]]
                , done: function (res, curr, count) {
                    console.log(res);
                    $("#kind1").val(res.data[0].Kind);//res.data[0].Kind表示获取到的链接中，data这个表格中的第一行的Kind这个值
                    $("#kind2").val(res.data[1].Kind);
                }
            });
            });
    </script>
</body>
</html>
